<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="/WEB-INF/views/taglib_include.jsp"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, target-densitydpi=medium-dpi, initial-scale=0.5, minimum-scale=0.5, maximum-scale=0.5, user-scalable=no" />
<meta content="yes" name="apple-mobile-web-app-capable" />
<meta content="black" name="apple-mobile-web-app-status-bar-style" />
<meta content="telephone=no" name="format-detection" />
<link href="${ctx}/css/layout.css?ver=${layout_css_version}" rel="stylesheet" type="text/css" />
<style type="text/css">
/*     .adbar { */
/*         text-align: center; */
/*         margin-top: 80pt; */
/*     } */
/*     /* 适配iphone5屏幕分辨率及以下屏幕分辨率 */ */
/*     @media screen and (max-width: 640px){ */
/*         .adbar { */
/*             text-align: center; */
/*             margin-top: 30px; */
/*         } */
/*     } */
</style>
<title>${projectTitle }</title>
</head>
<body>
  <header id="main-top">车票查询</header>
  <div id="container">
      <div id="departure">
        <h3>
          <span>出发车站</span><span>到达车站</span>
        </h3>
        <div>
          <span id="start-station"><c:if test="${empty ticketQueryParam.starting}">选择出发站</c:if><c:if test="${not empty ticketQueryParam.starting}">${ticketQueryParam.starting}</c:if></span>
          <img src="${ctx}/images/departure-bg.png" width="55" height="144">
          <span id="Destination"><c:if test="${empty ticketQueryParam.destination }">选择到达站</c:if><c:if test="${not empty ticketQueryParam.destination }">${ticketQueryParam.destination}</c:if></span>
        </div>
      </div>
      <div id="Dtime">
        <h3>出发日期</h3>
        <a href="${ctx}/trafficline/calendar.do?startCityId=${ticketQueryParam.startCityId}&starting=${ticketQueryParam.starting}&startStationId=${ticketQueryParam.startStationId}&arriveCityId=${ticketQueryParam.arriveCityId}&destination=${ticketQueryParam.destination }&arriveStationId=${ticketQueryParam.arriveStationId }&leaveDate=${ticketQueryParam.leaveDate}&startStationsDisabled=${ticketQueryParam.startStationsDisabled}&groupId=${ticketQueryParam.groupId}">
          <div>
            <span>
              <img src="${ctx}/images/inquiry_datetime_icon.png" width="28" height="30">
            </span>
            <span class="date"></span>
            ${year }年${month }月${day }日 ${dayName }
            <span class="more">
              <img src="${ctx}/images/more-icon.png" width="14" height="25">
            </span>
          </div>
        </a>
      </div>
  </div>
  <a href="javascript:;" id="queryButton">
    <div class="sumbit">查 询</div>
  </a>
  <c:if test="${appVer == constant.appver_hx}">
    <div class="adbar">
      <img src="${ctx}/images/浦发@2x.png">
    </div>
  </c:if>
  <form action="${ctx}/trafficline/enquiry.do" method="get">
    <input type="hidden" name="startCityId" value="${ticketQueryParam.startCityId}"/>
    <input type="hidden" name="startStationId" value="${ticketQueryParam.startStationId}"/>
    <input type="hidden" name="arriveCityId" value="${ticketQueryParam.arriveCityId}"/>
    <input type="hidden" name="arriveStationId" value="${ticketQueryParam.arriveStationId }"/>
    <c:if test="${not empty ticketQueryParam.leaveDate}">
    <input type="hidden" name="leaveDate" value="${ticketQueryParam.leaveDate}"/>
    </c:if>
    <c:if test="${empty ticketQueryParam.leaveDate}">
    <input type="hidden" name="leaveDate" value="${year}-${month}-${day}"/>
    </c:if>
    <input type="hidden" name="starting" value="${ticketQueryParam.starting}"/>
    <input type="hidden" name="destination" value="${ticketQueryParam.destination}"/>
    <input type="hidden" name="startStationsDisabled" value="${ticketQueryParam.startStationsDisabled}"/>
    <input type="hidden" name="groupId" value="${ticketQueryParam.groupId}"/>
  </form>
  <%@ include file="/WEB-INF/views/popup_alert.jsp"%>
  <script type="text/javascript" src="${ctx}/js/jquery.min.js?ver=${jquery_min_version}"></script>
  <!-- mergeTo:${ctx}/js/custom.min.js?ver=${custom_min_version} -->
  <script type="text/javascript" src="${ctx}/js/custom.js?ver=${custom_version}"></script>
  <!-- mergeTo -->
  <script type="text/javascript">
  $(document).ready(function() {
      var startCityId = $("input[name='startCityId']").val();
      var startStationId = $("input[name='startStationId']").val();
      var arriveCityId = $("input[name='arriveCityId']").val();
      var arriveStationId = $("input[name='arriveStationId']").val();
      var leaveDate = $("input[name='leaveDate']").val();

      // 点击选择出发站跳转到出发站列表页面
      <c:if test="${empty ticketQueryParam.startStationsDisabled}">
      $("#start-station").bind("click", function(e) {
          window.location.href = "${ctx}/station/startlist.do?startCityId=${ticketQueryParam.startCityId}&starting=${ticketQueryParam.starting}&startStationId=${ticketQueryParam.startStationId}&arriveCityId=${ticketQueryParam.arriveCityId}&destination=${ticketQueryParam.destination }&arriveStationId=${ticketQueryParam.arriveStationId }&leaveDate=${ticketQueryParam.leaveDate}&groupId=${ticketQueryParam.groupId}";
      });
      </c:if>
      // 点击选择到达站跳转到到达站列表页面
      $("#Destination").bind("click", function() {
    	  if (startCityId == "" && startStationId == "") {
    		  openAlert("请选择出发站");
    	  } else {
    		  window.location.href = "${ctx}/station/arrivelist.do?startCityId=${ticketQueryParam.startCityId}&starting=${ticketQueryParam.starting}&startStationId=${ticketQueryParam.startStationId}&arriveCityId=${ticketQueryParam.arriveCityId}&destination=${ticketQueryParam.destination }&arriveStationId=${ticketQueryParam.arriveStationId }&leaveDate=${ticketQueryParam.leaveDate}&startStationsDisabled=${ticketQueryParam.startStationsDisabled}&groupId=${ticketQueryParam.groupId}";
    	  }
      });
      // 点击查询按钮跳转到查询结果页面
      $("#queryButton").bind("click", function() {
    	  // 检查查询参数是否都已设置，否则提示选择参数
          if (startCityId == "" && startStationId == "") {
        	  openAlert("请选择出发站");
          } else if (arriveCityId == "" && arriveStationId == "") {
        	  openAlert("请选择到达站");
          } else if (leaveDate == "") {
        	  openAlert("请选择出发日期");
          } else {
        	  $("form").submit(); // 提交查询参数到车次查询
          }
      });
  });
  // 保存出发站参数
  localStorage.starting = "${ticketQueryParam.starting}";
  localStorage.startStationId = "${ticketQueryParam.startStationId}";
  localStorage.startStationsDisabled = "${ticketQueryParam.startStationsDisabled}";
  localStorage.startCityId = "${ticketQueryParam.startCityId}";
  localStorage.groupId = "${ticketQueryParam.groupId}";
  sessionStorage.removeItem('enquiryncUrl');
  </script>
</body>
</html>